#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> tr;

typedef long long LL;

const int N = 2e5 + 50;

int a[N];
LL f[N];


int n;
int pos[N];
LL s[N], p[N];

LL sum(LL x)
{
    return x * (x + 1) / 2;
}

LL sum(LL l, LL r)
{
    return sum(r) - sum(l-1);
}

struct SegTNode
{
    int num;
    LL v;
    SegTNode(int num = 0, LL v = 0): num(num), v(v)
    {

    }
    SegTNode operator + (const SegTNode &other) const
    {
        return SegTNode(num + other.num, v + other.v);
    }
};

struct SegT
{
    int nn, L, R;
    SegTNode dat[1 << 20];
    void init(int n)
    {
        for (nn = 1; nn < n; nn <<= 1);
        memset(dat, 0, sizeof(dat[0]) * (nn * 2));
    }

    inline void pu(int rt)
    {
        dat[rt] = dat[rt << 1] + dat[rt << 1 | 1];
    }

    inline void upt(int i, SegTNode x)
    {
        i += nn - 1;
        dat[i] = dat[i] + x;
        for (i >>= 1; i; i>>= 1)
        {
            pu(i);
        }
    }


    SegTNode sum(int l, int r, int rt)
    {
        if (L <= l && r <= R)
        {
            return dat[rt];
        }
        int mid = (l+r) >> 1;
        SegTNode res;
        if (L <= mid) res = res + sum(l, mid, rt<<1);
        if (mid+1<=R) res = res + sum(mid+1, r, rt<<1|1);
        return res;
    }

    inline SegTNode q(int l, int r)
    {
        L = l;
        R = r;
        return sum(1, nn, 1);
    }

    LL sum(int rank)
    {
        int rt = 1, l = 1, r = nn, base = 0;
        LL ans = 0;
        while (l != r)
        {
            // printf("%d %d\n", l, r);
            if (dat[rt << 1].num + base >= rank)
            {
                rt = rt << 1;
                r = (l + r) >> 1;
            }
            else
            {
                base += dat[rt << 1].num;
                ans += dat[rt << 1].v;
                rt = rt << 1 | 1;
                l = (l + r) / 2 + 1;
            }
        }
        ans += dat[rt].v;
        return ans;
    }
} seg;

int main(int argc, char const *argv[])
{
    scanf("%d", &n);

    seg.init(n);

    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &a[i]);
        pos[a[i]] = i;
    }

    tr.clear();
    for (int i=1; i<=n; ++i)
    {
        s[i] = s[i-1] + pos[i];
        p[i] = p[i-1] + seg.q(pos[i]+1, n).num;

        tr.insert(pos[i]);
        int midv = *tr.find_by_order((i+1)/2-1), mid = (i+1)/2;
        seg.upt(pos[i], SegTNode(1, pos[i]));
        LL sv = seg.sum((i+1)/2);

        f[i] = p[i] + sum(midv-mid+1 , midv) - sum(midv+1, midv+(i-mid)) + (s[i] - sv) - (sv);

        // printf("i=%d, s=%lld, p=%lld, f=%lld midv=%d, mid=%d sv=%lld\n", i, s[i], p[i], f[i], midv, mid, sv);
        
        printf("%lld%c", f[i], i==n? '\n':' ');
    }

    return 0;
}
